package com.ems.util;

import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import org.apache.poi.ss.usermodel.*;

/**
 * @Author: Wuzh
 * @Description:
 * @Date Created in 16:22 2023-05-27
 * @return
 */
public class ExcelUtil {

    /**
     * 标题样式
     *
     * @return
     */
    public static HorizontalCellStyleStrategy setExcelBasicStyle () {
        // 写入Excel中
        WriteCellStyle headWriteCellStyle = new WriteCellStyle ();
        //设置头字体
        WriteFont headWriteFont = new WriteFont ();
        headWriteFont.setFontHeightInPoints ( ( short ) 10 );
        headWriteFont.setFontName ( "微软雅黑" );
        headWriteFont.setBold ( true );
        headWriteCellStyle.setWriteFont ( headWriteFont );
        //设置头居中
        headWriteCellStyle.setHorizontalAlignment ( HorizontalAlignment.CENTER );
        //内容策略
        WriteCellStyle contentWriteCellStyle = new WriteCellStyle ();
        //设置 水平居中
        contentWriteCellStyle.setHorizontalAlignment ( HorizontalAlignment.CENTER );
        contentWriteCellStyle.setVerticalAlignment ( VerticalAlignment.CENTER );
        WriteFont contentFont = new WriteFont ();
        contentFont.setFontName ( "微软雅黑" );
        contentFont.setFontHeightInPoints ( ( short ) 10 );
        contentWriteCellStyle.setWriteFont ( contentFont );
        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy ( headWriteCellStyle, contentWriteCellStyle );
        return horizontalCellStyleStrategy;
    }


}
